package com.kdgz.kdgz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kdgz.kdgz.beans.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Desc 快递Mapper
 * @date 2021/3/18
 */
@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {

    @Select("select sum(`price`) from `orders`")
    public BigDecimal totalPrice();
    @Select("select sum(`price`) from `orders` where year(date)= #{year}")
    public BigDecimal totalPriceByYear(Integer year);
    @Select("select sum(`price`) from `orders` where year(date)= #{year} and month(date)= #{month}")
    public BigDecimal totalPriceByMonth(@Param("year") Integer year, @Param("month") Integer month);

    @Select("select sum(`price`) from `orders` where year(date)= #{year} and month(date)= #{month} and DAY(date) = #{day}")
    public BigDecimal totalPriceByDay(@Param("year") Integer year, @Param("month") Integer month, @Param("day") Integer day);

    @Select("select count(oid) from `orders` where year(date)= #{year} and month(date)= #{month}")
    public Integer totalOrdersByMonth(@Param("year") Integer year, @Param("month") Integer month);
    @Select("select count(oid) from `orders` where year(date)= #{year} and month(date)= #{month} and status = #{status}")
    public Integer totalOrdersByStatus(@Param("status") Integer status , @Param("year") Integer year, @Param("month") Integer month);

    public List<Orders> getAllOrders();

    public List<Orders> getOrdersBySid(Integer sid);

    public List<Orders> getOrdersBySidAndStatus(Integer sid,Integer status);

    public List<Orders> getOrdersBySidInMonth(Integer sid,Integer year,Integer month);

    public List<Orders> getOrdersByStatus(Integer status);

    @Select("select * from orders o where oid not in \n" +
            "(select oid from staff_orders)")
    public List<Orders> getOrdersForSend();
}
